home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / c.dxr / 00011_CChaosFuncAnimator.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  2.2 KB  |  73 lines

  1. property ancestor, pPathFunctionData, pCurrentLoc, pStartLoc, pRefName
  2.  
  3. on birth me, arguments
  4.   set the ancestor of me to birth(script "Animator", arguments)
  5.   set the pPathFunctionData of me to the pathData of arguments
  6.   set pStartLoc to the location of arguments
  7.   set pRefName to the RefName of arguments
  8.   set pCurrentLoc to pStartLoc
  9.   return me
  10. end
  11.  
  12. on moveSprite me
  13.   set theResult to chaoticLoc(me)
  14.   set the pCurrentLoc of me to theResult
  15.   set the loc of sprite the pChannel of me to the pCurrentLoc of me
  16. end
  17.  
  18. on chaoticLoc me
  19.   global gA, gY
  20.   set OBJref to the pRefName of me
  21.   set gA to 3.89999999999999991
  22.   set gY to 0.19999999999999998
  23.   if voidp(getaProp(getaProp(gObjects, pRefName), #animator)) then
  24.     set lastPoint to getaProp(getaProp(gObjects, pRefName), #onloc)
  25.   else
  26.     set lastPoint to the pCurrentLoc of getaProp(getaProp(gObjects, pRefName), #animator)
  27.   end if
  28.   set graphData to getaProp(getaProp(gObjects, pRefName), #graphList)
  29.   set lastY to getaProp(graphData, #lastY)
  30.   set V to the locV of lastPoint
  31.   set graphLeft to getaProp(graphData, #minHLoc)
  32.   set graphRight to getaProp(graphData, #maxHLoc)
  33.   set graphBottom to getaProp(graphData, #maxVLoc)
  34.   set graphTop to getaProp(graphData, #minVLoc)
  35.   set graphHeight to float(graphBottom - graphTop)
  36.   set scaledGraphHeight to graphHeight * 0.75
  37.   set m to 1
  38.   set dw to getaProp(graphData, #frameHStep)
  39.   set a to gA
  40.   set H to the locH of lastPoint
  41.   if H = graphLeft then
  42.     erasegraphs()
  43.   end if
  44.   set H to the locH of lastPoint + dw
  45.   if H >= graphRight then
  46.     set H to graphLeft
  47.   end if
  48.   if V > 10000 then
  49.     return point(H, 20000)
  50.   end if
  51.   if lastY = #NULL then
  52.     set chaosSeedY to getaProp(graphData, #chaosSeedY)
  53.     set yn to chaosSeedY
  54.   else
  55.     set yn to lastY
  56.   end if
  57.   repeat with i = 1 to m
  58.     set yn to a * yn * (1 - yn)
  59.   end repeat
  60.   setaProp(graphData, #lastY, yn)
  61.   set V to integer(graphTop + (0.5 * (graphHeight - scaledGraphHeight)) + ((1 - yn) * scaledGraphHeight))
  62.   set aloc to point(H, V)
  63.   return aloc
  64. end
  65.  
  66. on erasegraphs
  67.   set OBj to getaProp(gObjects, #barGraphBkgnd)
  68.   set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(OBj, #offloc)
  69.   updateStage()
  70.   set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(OBj, #onloc)
  71.   updateStage()
  72. end
  73.